#include <iostream>
using namespace std;

/*头文件*/
#include <fstream>
#include <stdio.h>
#include <iomanip>


class Fstream
{
public:

};


int main()
{
#if 0
    int num = 100;
    printf("num:%d\n", num);
    printf("num:%12d\n", num);


    printf("num:123456789123\n");
    cout<<"num"<<setw(12)<< 777<<endl;
#endif
    const char * name = "./test.txt";
#if 0
    /*使用构造函数的方式打开文件*/
    ofstream ofs(name);
    /*判断文件是否打开成功*/
    if (ofs.is_open())
    {
        cout<<"open sucess"<<endl;
    }
    ofs.close();
#else 
    ofstream ofs;
    /*open成员函数 打开文件
        mode默认是ios::out | ios::trunc
        ios::app:
        */
    ofs.open(name);
    /*判断文件是否打开成功*/
    if (ofs.is_open())
    {
        cout<<"open sucess"<<endl;
    }
    /*将数据写到文件*/
    ofs<<"hello world\n";

#endif
    return 0;
}